#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char *argv[])
{
    // How to get program path?
    puts("dirname readlink:");
    system("dirname $(readlink -f $0)");
    char sss[10000];
    puts("dirname argv[0]:");
    sprintf(sss, "dirname %s", argv[0]);
    system(sss);
    puts("getcwd:");
    puts(getcwd(sss, 10000));
    puts("realpath:");
    realpath(argv[0], sss);
    int i, ssslen = strlen(sss);
    for(i = ssslen - 1; i >= 0; -- i)
        if(sss[i] == '/')
        {
            sss[i] = 0;
            break;
        }
    puts(sss);
    sprintf(sss, "%s/mafft/staralign", sss);
    if(access(sss, X_OK))
        puts("gg staralign");
    else puts("OK staralign");
    sprintf(sss, "%s -H", sss);
    system(sss);
    return 0;
}